import java.awt.Point;
import java.util.ArrayList;


public class DataControl {
	private ArrayList<ArrayList<Long>> dataSets;
	private ArrayList<String> pickedHistory;
	private ArrayList<Integer> largestDatas;
	private int largestData;
	private int largestSize;

	public DataControl()
	{
		dataSets=new ArrayList<ArrayList<Long>>();
		pickedHistory=new ArrayList<String>();
		largestDatas=new ArrayList<Integer>();
		largestSize=0;
		largestData=0;
	}
	
	public void addDataSet(ArrayList<Long> newData) 
	{
		dataSets.add(newData);
		if (newData.size()>largestSize)
		{
			largestSize=newData.size();
		}
	}

	public int getLargestData()
	{
		return largestData;
	}
	
	public int getLargestSize()
	{
		return largestSize;
	}
	
	public ArrayList<ArrayList<Point>> getDataForGraph() {
		ArrayList<ArrayList<Point>> toReturn=new ArrayList<ArrayList<Point>>();
		int currentLargest=0;
		for (ArrayList<Long> dataSet: dataSets)
		{
			ArrayList<Point> points=new ArrayList<Point>();
			for (int i=0;i<dataSet.size();i++)
			{
				int nowData=(dataSet.get(i)).intValue();
				if (nowData>currentLargest)
				{
					currentLargest=nowData;
				}
				points.add(new Point(i,nowData));
			}
			toReturn.add(points);
		}
		if (currentLargest>largestData)
		{
			largestData=currentLargest;
		}
		largestDatas.add(currentLargest);
		return toReturn;
	}

	public void clearData() 
	{
		dataSets=new ArrayList<ArrayList<Long>>();
		pickedHistory=new ArrayList<String>();
		largestDatas=new ArrayList<Integer>();
		largestSize=0;
		largestData=0;
	}
	
	public void removeData(int which) 
	{
		dataSets.remove(which);
		pickedHistory.remove(which);
		largestDatas.remove(which);
		largestSize=0;
		largestData=0;
		for (int i=0;i<dataSets.size();i++)
		{
			if (largestDatas.get(i)>largestData)
			{
				largestData=largestDatas.get(i);
			}
			if (dataSets.get(i).size()>largestSize)
			{
				largestSize=dataSets.get(i).size();
			}
		}
	}

	public ArrayList<String> getPickedHistory() 
	{
		if (pickedHistory==null)
		{
			return new ArrayList<String>();
		}
		return pickedHistory;
	}

	public void updateOptionsPicked(ArrayList<String> optionsPicked) {
		// TODO Auto-generated method stub
		String picked="";
		for(int i=0;i<optionsPicked.size();i++)
		{
			picked+=optionsPicked.get(i)+"-";
		}
		pickedHistory.add(picked);
	}

	
	
	
}
